package com.softhinker.ke24.unit3.model;

import java.io.Serializable;

public class GreedLevel implements Serializable{

	private static final long serialVersionUID = -6753922156661500514L;

	private double expectedROI = 0.0;
	private int investmentTimeSpan = 0;//in days
	/**
	 * -1 : lower than buying price
	 * 0 : between buying price and expected ROI
	 * 1 : equal to expected ROI
	 */
	private int acceptedSellingPoint = 0;
	
	public double getExpectedROI() {
		return expectedROI;
	}
	public void setExpectedROI(double expectedROI) {
		this.expectedROI = expectedROI;
	}
	public int getInvestmentTimeSpan() {
		return investmentTimeSpan;
	}
	public void setInvestmentTimeSpan(int investmentTimeSpan) {
		this.investmentTimeSpan = investmentTimeSpan;
	}
	public int getAcceptedSellingPoint() {
		return acceptedSellingPoint;
	}
	public void setAcceptedSellingPoint(int acceptedSellingPoint) {
		this.acceptedSellingPoint = acceptedSellingPoint;
	}
	
	@Override
	public String toString(){
		return "Expected ROI : " + this.getExpectedROI() * 100 + "%\n"
				+ "Investment time span : " + this.getInvestmentTimeSpan() + " days\n"
				+ "Accepted selling point : " + this.getAcceptedSellingPoint();
	}
	
	public int getValue(){
		double rpy = this.getExpectedROI() * 365 / this.getInvestmentTimeSpan();
		
		int value = 0;
		
		if(0 < rpy && rpy <= 0.1){
			switch(this.getAcceptedSellingPoint()){
				case 0 : value = 2;
						 break;
				case 1 : value = 3;
						 break;
				case -1 : value = 1;
						 break;
			}
		} else if(0.1 < rpy && rpy <= 0.3){
			switch(this.getAcceptedSellingPoint()){
				case 0 : value = 4;
						 break;
				case 1 : value = 5;
						 break;
				case -1 : value = 3;
						 break;
			}
		} else if(0.3 < rpy && rpy <= 0.6){
			switch(this.getAcceptedSellingPoint()){
				case 0 : value = 6;
						 break;
				case 1 : value = 7;
						 break;
				case -1 : value = 5;
						 break;
			}
		} else if(0.6 < rpy){
			switch(this.getAcceptedSellingPoint()){
				case 0 : value = 9;
						 break;
				case 1 : value = 10;
						 break;
				case -1 : value = 8;
						 break;
			}
		}
		
		return value;
	}
}
